home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / byteibm.arc / PROTECT.INC < prev    next >
Text File  |  1985-07-12  |  5KB  |  203 lines

  1. .286C
  2. .SALL
  3. .XLIST
  4.  
  5. ;This file provides macros to simulate PM286 instructions not
  6. ;supported by MASM V2.0.  Some macros do simple operand checking, but
  7. ;it is possible to generate illegal instructions if you aren't
  8. ;careful.  The opcodes simulated are:
  9. ;       ARPL   CLTS   LAR
  10. ;       LGDT   LIDT   LLDT
  11. ;       LMSW   LSL    LTR
  12. ;       SGDT   SIDT   SLDT
  13. ;       SMSW   STR    VERR
  14. ;       VERW
  15. ;
  16. arpl    MACRO     ew, rw      ;; ADJUST RPL
  17.         LOCAL     start, end
  18.         start = $
  19.         IFDEF     ew          ;; is ew defined symbol?
  20.         add       WORD PTR ew, rw
  21.         ELSE                  ;; assume ew is register
  22.         add       ew, rw
  23.         ENDIF
  24.         end = $
  25.         ORG       start
  26.         DB        63h
  27.         ORG       end
  28.         ENDM
  29.  
  30. clts    MACRO                 ;; CLEAR TS BIT
  31.         DB        0Fh, 06h
  32.         ENDM
  33.  
  34. lar     MACRO     rw, ew      ;; LOAD ACCESS RIGHTS
  35.         LOCAL     start, end
  36.         DB        0Fh
  37.         start = $
  38.         add       rw, ew
  39.         end = $
  40.         ORG       start
  41.         DB        02h
  42.         ORG       end
  43.         ENDM
  44.  
  45. lgdt    MACRO     mem         ;; LOAD GDT REGISTER
  46.         DB        0Fh
  47.         add       WORD PTR mem, dx
  48.         ENDM
  49.  
  50. lidt    MACRO     mem         ;; LOAD IDT REGISTER
  51.         DB        0Fh
  52.         add       WORD PTR mem, bx
  53.         ENDM
  54.  
  55. lldt    MACRO     ew          ;; LOAD LDT REGISTER
  56.         LOCAL     start, end
  57.         DB        0Fh
  58.         start = $
  59.         rcl       ew, 1
  60.         end = $
  61.         ORG       start
  62.         DB        0
  63.         ORG       end
  64.         ENDM
  65.  
  66. lmsw    MACRO     ew          ;; LOAD MACHINE STATUS WORD
  67.         LOCAL     start, end
  68.         DB        0Fh
  69.         start = $
  70.         div       ew
  71.         end = $
  72.         ORG       start
  73.         DB        1
  74.         ORG       end
  75.         ENDM
  76.  
  77. lsl     MACRO     rw, ew      ;; LOAD SEGMENT LIMIT
  78.         LOCAL     start, end
  79.         DB        0Fh
  80.         start = $
  81.         add       rw, ew
  82.         end = $
  83.         ORG       start
  84.         DB        03h
  85.         ORG       end
  86.         ENDM
  87.  
  88. ltr     MACRO     ew          ;; LOAD TASK REGISTER
  89.         LOCAL     start, end
  90.         DB        0Fh
  91.         start = $
  92.         rcr       ew, 1
  93.         end = $
  94.         ORG       start
  95.         DB        0
  96.         ORG       end
  97.         ENDM
  98.  
  99. sgdt    MACRO     mem         ;; STORE GDT REGISTER
  100.         DB        0Fh
  101.         add       WORD PTR mem, ax
  102.         ENDM
  103.  
  104. sidt    MACRO     mem         ;; STORE IDT REGISTER
  105.         DB        0Fh
  106.         add       WORD PTR mem, cx
  107.         ENDM
  108.  
  109. sldt    MACRO     ew          ;; STORE LDT REGISTER
  110.         LOCAL     start, end
  111.         DB        0Fh
  112.         start = $
  113.         rol       ew, 1
  114.         end = $
  115.         ORG       start
  116.         DB        0
  117.         ORG       end
  118.         ENDM
  119.  
  120. smsw    MACRO     ew          ;; STORE MACHINE STATUS WORD
  121.         LOCAL     start, end
  122.         DB        0Fh
  123.         start = $
  124.         shl       ew, 1
  125.         end = $
  126.         ORG       start
  127.         DB        1
  128.         ORG       end
  129.         ENDM
  130.  
  131. str     MACRO     ew          ;; STORE TASK REGISTER
  132.         LOCAL     start, end
  133.         DB        0Fh
  134.         start = $
  135.         ror       ew, 1
  136.         end = $
  137.         ORG       start
  138.         DB        0
  139.         ORG       end
  140.         ENDM
  141.  
  142. verr    MACRO     ew          ;; VERIFY READ ACCESS
  143.         LOCAL     start, end
  144.         DB        0Fh
  145.         start = $
  146.         shl       ew, 1
  147.         end = $
  148.         ORG       start
  149.         DB        0
  150.         ORG       end
  151.         ENDM
  152.  
  153. verw    MACRO     ew          ;; VERIFY WRITE ACCESS
  154.         LOCAL     start, end
  155.         DB        0Fh
  156.         start = $
  157.         shr       ew, 1
  158.         end = $
  159.         ORG       start
  160.         DB        0
  161.         ORG       end
  162.         ENDM
  163.  
  164. ;
  165. ;This macro must be used in place of the standard segment override
  166. ;in conjuction with the above macros.  The standard segment override
  167. ;will be attached to the wrong portion of the instruction, e.g., after
  168. ;the 0Fh in an LGDT instruction.
  169. ;
  170. ;DO NOT USE:
  171. ;       LGDT      ES:[my_gdt]
  172. ;
  173. ;CODE THIS INSTEAD:
  174. ;       SEGOV     ES
  175. ;       LGDT      [my_gdt]
  176. ;
  177. segov   MACRO     s           ;; seg override for 286 macros
  178.         IFIDN     <s>,<ES>
  179.         DB        26h
  180.         ENDIF
  181.         IFIDN     <s>,<CS>
  182.         DB        2Eh
  183.         ENDIF
  184.         IFIDN     <s>,<SS>
  185.         DB        36h
  186.         ENDIF
  187.         IFIDN     <s>,<DS>
  188.         DB        3Eh
  189.         ENDIF
  190.         ENDM
  191.  
  192.         .LIST
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.